﻿@model SuperDumpService.ViewModels.BundleViewModel
@{
	ViewData["Title"] = "Created";
}

<h3>Analysis ID <strong>@Model.BundleId</strong></h3>
@if (Model.Status == SuperDumpService.Models.BundleStatus.Failed) {
	<h4>Bundle failed...</h4>
	<pre>@Model.ErrorMessage</pre>
}  else if (Model.Status == SuperDumpService.Models.BundleStatus.Duplication) {
	<h4>This dump was already analyzed: <a href="/Home/BundleCreated?bundleId=@Model.OriginalBundleId">@Model.OriginalBundleId</a>.</h4>
} else if (Model.Status != SuperDumpService.Models.BundleStatus.Finished) {
	<h4>..hang tight, bundle gets created..</h4>
	<script>
	setTimeout(function () {
		window.location.reload(1);
	}, 2000);
	</script>
} else {
	if (!Model.DumpInfos.Any()) {
		<h4>Bundle failed...</h4>
		<pre>No files found in bundle.</pre>
	} else if (Model.DumpInfos.Count() == 1) {
		var item = Model.DumpInfos.First();
		<h3>
		Dump with id <strong><a href="@SuperDumpService.Helpers.Utility.GetDumpUrl(item.DumpInfo.Id)">@item.DumpInfo.DumpId</a></strong> successfully created.</h3>

		<p>You'll be redirected to the report...</p>
		<script>
			window.location.replace("@SuperDumpService.Helpers.Utility.GetDumpUrl(item.DumpInfo.Id)");
		</script>
	} else {
		<h3>You uploaded a zip file with several dumps.</h3>
		<ul>
			@foreach (var item in Model.DumpInfos) {
				<li><strong><a href="@SuperDumpService.Helpers.Utility.GetDumpUrl(item.DumpInfo.Id)">@item.DumpInfo.DumpId (@System.IO.Path.GetFileName(item.DumpInfo.DumpFileName))</a></strong> successfully created.</li>
			}
		</ul>
	}
}
